package com.cy.pj.goods.activity.dao;

import com.cy.pj.goods.activity.pojo.Goods;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public class GoodsDaoImpl implements  GoodsDao{
    @Autowired
    private SqlSessionFactory sqlSessionFactory;

    @Override
    public List<Goods> findGoods() {
        //1.获取对象
        SqlSession session = sqlSessionFactory.openSession();
        //2.基于sqlsseion实现商品查询
        String statement = "com.cy.pj.goods.activity.dao.GoodsDao.findGoods"; //namespace+elementId
        List<Goods> list = session.selectList(statement);
        //3.释放资源
        session.close();
        //4.返回结果
        return list;

    }
}
